home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Mops 2.7 / Mops source / Toolbox classes / GWorld < prev    next >
Encoding:
Text File  |  1995-11-23  |  1.6 KB  |  77 lines  |  [TEXT/MSET]

  1. \ GWorld Class
  2. \ e d - b o y
  3. \ 951013
  4.  
  5. \ This only works in 8-bit colour at the moment
  6. \ Remember to allocate plenty of memory to Mops if you're using this
  7.  
  8. \ some useful words
  9.  
  10. ptr        origPort
  11. handle    origDevice
  12.         
  13. : EnterGWorld
  14.     origPort origDevice call GetGWorld ;
  15.  
  16. : ExitGWorld
  17.     get: origPort get: origDevice call SetGWorld ;
  18.  
  19.  
  20. :class GWORLD super{ object }
  21.     ptr        GWorldPtr
  22.     handle    PixMap
  23.     handle    CTable
  24.     handle    gDHandle
  25.     rect    Bounds
  26.   4    bytes    flags
  27.         
  28. :m SETBOUNDS: \ ( l t r b -- )
  29.     put: bounds ;m
  30.  
  31. :m NEW:
  32.     GWorldPtr 0 makeint bounds PixMap CTable flags call NewGWorld ;m
  33.  
  34. :m PEEK:    \ useful for debugging (returns zero or nilp if GWorld not created
  35.     get: GWorldPtr . cr ;m
  36.  
  37. :m PEEKPM:    \ ditto
  38.     get: PixMap . cr ;m
  39.  
  40. :m GETPMHANDLE:        \ creates PixMap and stores its handle
  41.     0 get: GWorldPtr call GetGWorldPixMap put: PixMap ;m
  42.  
  43. :m GETGDHANDLE:        \ sets graphic device handle
  44.     0 get: GWorldPtr call GetGWorldDevice put: gDHandle ;m
  45.  
  46. :m SET:                \ makes GWorld current port
  47.     get: GWorldPtr get: gDHandle call SetGWorld ;m
  48.  
  49.  
  50. :m LOCKPIXELS:    \ ( -- bool )  TRUE if GWorld ready for drawing
  51.     get: PixMap  call LockPixels ;m
  52.  
  53. :m UNLOCKPIXELS:
  54.     get: PixMap call UnlockPixels ;m
  55.         
  56. :m GETPIXBASEADDR:    \ ( -- ptr ) included for block moves between GWorlds
  57.     0 get: PixMap   call GetPixBaseAddr ;m
  58.  
  59. :m DISPOSE:
  60.     get: GWorldPtr call DisposeGWorld ;m
  61.  
  62. :m RELEASE:            \ mh - normal Mops destructor method
  63.     dispose: self  ;m
  64.     
  65. :m CREATE:    \ ( l r t b -- ) quick way to make a GWorld
  66.     setBounds: self
  67.     new: self
  68.     getPMHandle: self
  69.     getGDHandle: self
  70. ;m
  71.  
  72. :m GETPORTPIXMAP: \ compatible with GrafPort call (bit of a kludge)
  73.     get: GWorldPtr 2 + ;m
  74.  
  75. ;class
  76.  
  77.